import 'dart:convert';
import 'dart:developer';

import 'package:dio/dio.dart';
import 'package:get/get.dart';
import 'package:get/get_connect/connect.dart';
import 'package:jxchmz/Getx%E5%B7%A5%E5%85%B7/GetxTools.dart';
import 'package:jxchmz/Getx%E5%B7%A5%E5%85%B7/KSProgressDialog.dart';
import 'package:shared_preferences/shared_preferences.dart';

class LoginApi  {
  String ApiUrl = "http://182.92.194.138:8080";
  Dio dio = new Dio();
  var ResponseData;
  // 获取本地token
 void configDio() async {
    dio.options.connectTimeout=5000;
    dio.options.receiveTimeout=3000;
  }
//  登录
Login(Data) async {
  //配置dio
  configDio();
  try{
    ResponseData = await dio.post(ApiUrl+"/login", data: Data);
    print("请求参数$Data");
    if (ResponseData.statusCode == 200) {
      // 请求成功
      ResponseData = json.decode(ResponseData.toString());
      log("数据返回:$ResponseData");
      return ResponseData;
    }else{
      log("请求失败，状态码:${ResponseData.statusCode}");
      GetxTools().ErrorToast("系统异常");
      return "";
    }
    // 491989067
  }catch(e){
    log("异常，${e.reactive}");
    GetxTools().ErrorToast("系统异常");
    return "";
  }
}



}
